package com.yeeverse.api.demo.test.h5;

import com.alibaba.fastjson.JSON;
import com.yeeverse.api.demo.test.BaseTest;
import com.yeeverse.sdk.api.PaycenterApi;
import com.yeeverse.sdk.util.JsonUtils;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class SaasH5 extends BaseTest {


    @Test
    //生产环境
    public void test1() throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("parentMerchantNo", "3001000004089110");
        map.put("requestNo", "gy" + System.currentTimeMillis());
        map.put("merchantUserId", "yangkai2");
        map.put("redirectUrl", "https://www.baidu.com");
        System.out.println("请求参数="+ JsonUtils.toJsonString(map));
        Map mapRspDataVO = new PaycenterApi().baseRequest(map, "/v2/rest/authRealName", Map.class);
        System.out.println("解密response报文：" + JSON.toJSONString(mapRspDataVO));
    }

    @Test
    //生产环境
    public void test2() throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("parentMerchantNo", "3001000004089110");
        map.put("requestNo", "gy1667533311012");
        map.put("merchantUserId", "yangkai");
        System.out.println("请求参数="+ JsonUtils.toJsonString(map));

        Map mapRspDataVO = new PaycenterApi().baseRequest(map, "/v2/rest/queryAuthName", Map.class);
        System.out.println("解密response报文：" + JSON.toJSONString(mapRspDataVO));
    }

    @Test
    //生产环境
    public void test3() throws Exception {
        //跳转拿个类型页面，1. HOME（首页）、2。MINE(我的)：、。SHOP(藏品)：、4。DETAIL
        String choose="MINE";

        Map<String, Object> map = new HashMap<>();
        map.put("parentMerchantNo", "3001000004089110");
        map.put("merchantUserId", "yangkai");

        System.out.println("请求参数="+ JsonUtils.toJsonString(map));

        Map mapRspDataVO = new PaycenterApi().baseRequest(map, "/v2/rest/getNassAuthCode", Map.class);
        System.out.println("解密response报文：" + JSON.toJSONString(mapRspDataVO));

        Object naasAuthCode = mapRspDataVO.get("naasAuthCode");
        String h5Url="http://123.60.244.80:9998/api/marketing-web/saas?redirctType=%s&naasAuthCode=%s";
        // 测试环境地址：http://123.60.244.80:9998/api/marketing-web/saas?redirctType=%s&naasAuthCode=%s
        // 生产环境地址：。。。
        if(naasAuthCode!=null){
            String format = String.format(h5Url, choose, naasAuthCode);
            System.out.println("可以跳转地址为="+format);
        }else {
            System.out.println("获取code失败！");
        }


    }

    @Test
    //生产环境
    public void test4() throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("parentMerchantNo", "3001000004089110");
        map.put("requestNo", "kt" + System.currentTimeMillis());
        map.put("merchantUserId", "yangkai");
        map.put("goodId", "358");
        map.put("reserveNo","2");
        System.out.println("空投藏品请求参数"+JsonUtils.toJsonString(map));

        Map mapRspDataVO = new PaycenterApi().baseRequest(map, "/v2/rest/sendAirdrop", Map.class);
        System.out.println("解密response报文：" + JSON.toJSONString(mapRspDataVO));
    }

    @Test
    //生产环境
    public void test5() throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("parentMerchantNo", "3001000004089110");
        map.put("sourceRequestNo", "kt1667547693350");

        System.out.println("请求参数" + JSON.toJSONString(map));
        Map mapRspDataVO = new PaycenterApi().baseRequest(map, "/v2/rest/querySendAirdrop", Map.class);

        System.out.println("解密response报文：" + JSON.toJSONString(mapRspDataVO));
    }

}
